<?php
declare(strict_types=1);
namespace app\admin\controller\home;

use app\admin\service\home\IndexService;
use app\common\controller\AdminBase;

class Index extends AdminBase{

    /**
     * 获取登录菜单
     */
    public function get_menu()
    {
        $res = IndexService::getAdminMenu($this->admin);
        // 用户菜单
//        $data = $this->getTreeOrder($res);
        $data = $this->getTreeActionAndMenu($res);
//        print_r($data);exit;
        return suc('成功', $data);
    }

    /**
     * 上传图片/文件
     */
    public function user_upload_img(){
        $folder = $this->request->post('folder'); //文件夹名称
        if(!empty($folder)) {
            $path = date('Y-m').'/'.date('d').'/'.$folder ;
             $img = uploadImage($path);
             return $img;
        }
        return suc('失败','',0);
    }
    /**
     * 后台首页统计数据
     */
    public function get_data_in_index(){
        $key = $this->request->get('key');
        $res = [
            'user'=>44,
            'group'=>base64_encode('55'),
            'admin'=>$this->admin
        ];

        return suc('成功',$res);
    }
}